<?php

class re_form_form extends re_dom_form
{
	
	public function __construct($name=null)
	{
		parent::__construct();
	}
	
	public function getValues()
	{
		return $_POST;
	}
	
	public function associateValues()
	{

	}
	
	public function validate($values=array())
	{
		$valid = true;
		
		foreach($this->children as $child)
		{
			if(is_a($child, 'form_element'))
			{
				if($child->validate($values[$child->getName()])==false)
				{
					$child->setValue($values[$child->getName()]);
					$valid = false;
				};
			}
			else
			{
				if(method_exists($child, 'validate'))
				{
					if($child->validate($values)==false)
					{
						$valid = false;
					}	
				}
			}
		}
		
		return $valid;
	}
	
	public function __toString()
	{
		echo $this->validate($this->getValues());
		return parent::__toString();
	}
}

?>